#ifndef TIMER_H_
#define TIMER_H_

#include <time>
#include <iostream>

class Timer {
public:
	void begin() {
		timespec ts;
		if (0 != clock_gettime(CLOCK_REALTIME, &ts) ) {
			std::cout << "Nao consegui pegar time no begin()" << std::endl;
		}
		else
			theBegin = ts.tv_sec + double(ts.tv_nsec)/1000000000;
	}
	void end() {
		timespec ts;
		if (0 != clock_gettime(CLOCK_REALTIME, &ts) ) {
			std::cout << "Nao consegui pegar time no end()" << std::endl;
		}
		else
			theEnd = ts.tv_sec + double(ts.tv_nsec)/1000000000;
	}
	
	double diff() { 
		return theEnd - theBegin; 
	}
	
private:
	double theBegin;
	double theEnd;
	
};

#endif /*TIMER_H_*/
